#version 130

uniform sampler2DShadow map_shadow0;
uniform sampler2DShadow map_shadow1;
uniform sampler2DShadow map_shadow2;

in vec4 pos[3];

bool test (vec4 p)
{
	vec3 pr = p.xyz / p.w;
	return pr.x >= 0.0 && pr.x <= 1.0 && pr.y >= 0.0 && pr.y <= 1.0;
}

void main(void)
{
	float result = 1.0;

	if (test (pos[0]))
	{
		result = shadow2DProj (map_shadow0, pos[0]).x;
	}
	else if (test(pos[1]))
	{
		result = shadow2DProj (map_shadow1, pos[1]).x;
	}
	else if (test(pos[2]))
	{
		result = shadow2DProj (map_shadow2, pos[2]).x;
	}
	if (result < 0.5)
	{
		gl_FragColor = vec4 (0.5, 0.5, 0.5, 1.0);
	}
	else
	{
		gl_FragColor = vec4 (1.0, 1.0, 1.0, 1.0);
	}
}
